function modal_pageOperation($scope, pageObject) {
    /**
     * 初始化pageList
     * @param page
     */
    $scope.modal_selectPage = function (page) {
        //不能小于1大于最大
        if (page < 1 || page > $scope.modal_pages) return;
        var newpageList = [];
        if (page > 1) {
            for (var i = 0 ; i < ((page + 1) > $scope.modal_pages ? $scope.modal_pages : (page + 1)) ; i++) {
                newpageList.push(i + 1);
            }
            $scope.modal_pageList = newpageList;
        }
        $scope.modal_selPage = page;
        $scope.modal_isActivePage(page);
    };
    /**
     * 设置当前选中页样式
     * @param page
     * @returns {boolean}
     */
    $scope.modal_isActivePage = function (page) {
        $("#modal_top").removeClass("disabled");
        $("#modal_bottom").removeClass("disabled");
        $("#modal_previous").removeClass("disabled");
        $("#modal_next").removeClass("disabled");
        if($scope.modal_selPage==1){
            $("#modal_top").addClass("disabled");
            $("#modal_previous").addClass("disabled");
        }//追加头部不可用样式
        if($scope.modal_selPage==$scope.modal_pages){
            $("#modal_bottom").addClass("disabled");
            $("#modal_next").addClass("disabled");
        }//追加末尾样式
        //if($scope.page > $scope.pages || $scope.page == null){
        //    $("#go").addClass("disabled");
        //}else{
        //    $("#go").removeClass("disabled");
        //}
        return $scope.modal_selPage == page;
    };
    //选中页
    $scope.modal_selectCurrentPage = function (page) {
        if(page != undefined && page > $scope.modal_pages){
            promptMsg("请输入正确页数！");
            $scope.modal_page = '';
            return false;
        }
        if(page == null || page == ''){
            $scope.modal_selPage = 1;
        }else{
            $scope.modal_selPage = page;
        }
        $scope.modal_findByCondition();
    }
    //首页
    $scope.modal_firstPage = function () {
        if($scope.modal_selPage == 1){
            return
        }
        $scope.modal_selPage = 1;
        $scope.modal_findByCondition();
    }
    //上一页
    $scope.modal_previous = function () {
        if($scope.modal_selPage == 1){
            return
        }
        $scope.modal_selPage = $scope.modal_prePage;
        $scope.modal_findByCondition();
    }
    //下一页
    $scope.modal_next = function () {
        if($scope.modal_selPage == $scope.modal_pages){
            return
        }
        $scope.modal_selPage = $scope.modal_nextPage;
        $scope.modal_findByCondition();
    };
    //尾页
    $scope.modal_lastPage = function () {
        if($scope.modal_selPage == $scope.modal_pages){
            return
        }
        $scope.modal_selPage = $scope.modal_pages;
        $scope.modal_findByCondition();
    };
    /**
     * 改变分页显示条数
     * @param pageSize
     */
    $scope.modal_changePageSize = function(pageSize) {
        if(pageSize != undefined && $scope.modal_pageSize == pageSize){
            return false;
        }
        $scope.modal_selPage = 1;
        $scope.modal_pageSize = pageSize;
        $scope.modal_page = '';
        // 回调函数
        $scope.modal_findByCondition();
    }

    /**
     * 同一个页面有多个分页时，先重置分页参数
     */
    $scope.modal_resetPage = function() {
        //重新初始化查询
        $scope.modal_selectPageSize = "10"
        //重新指定第1页
        $scope.modal_selPage = "1";
        //跳转页数清空
        $scope.modal_page = '';
        // 回调函数
        $scope.modal_findByCondition();
    }
    /**
     * 排序
     */
    $scope.modal_setSort = function(sort) {
        if (sort == $scope.modal_sort) {
            $scope.modal_desc = !$scope.modal_desc;
        } else {
            $scope.modal_sort = sort;
            $scope.modal_desc = false;
        }
        $scope.modal_resetPage();
    }
    /**
     * 排序样式
     */
    $scope.modal_sortClass = function(field) {
        if (field != $scope.modal_sort) {
            return "header-sort";
        } else if ($scope.modal_desc) {
            return "header-sort header-sort-desc";
        } else {
            return "header-sort header-sort-asc";
        }
    };

    modal_startPage($scope,pageObject);
}
/**
 * 开始分页
 * @param $scope
 * @param pageObject
 */
function modal_startPage($scope,pageObject){
    //页面大小
    $scope.modal_pageSize = pageObject.pageSize;
    $scope.modal_pages = pageObject.pages;
    $scope.modal_newPages = $scope.modal_pages > 1 ? 1 : $scope.modal_pages;
    $scope.modal_pageList = [];
    for (var i = 0; i < $scope.modal_newPages; i++) {
        $scope.modal_pageList.push(i + 1);
    }
    //当前页面
    $scope.modal_selPage = pageObject.pageNum;
    $scope.modal_total = pageObject.total;
    $scope.modal_prePage = pageObject.prePage > 0 ? pageObject.prePage : 1;
    $scope.modal_nextPage = pageObject.nextPage > pageObject.pages ? pageObject.pages : pageObject.nextPage ;
    $scope.modal_startRow = pageObject.startRow;
    $scope.modal_endRow = pageObject.endRow;
    $scope.modal_selectPage($scope.modal_selPage);
}
